﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entidades;
using UVM_Utileria;
using UVM_Pretira_BL;

public partial class LoggingPretira : System.Web.UI.Page
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        Session["Usuario"] = null;
        Validacion.Style.Add("display", "none");
        
       
    }
    protected void bLog_Click(object sender, EventArgs e)
    {
        Usuario usr = new Usuario();
        usr.UserName = user.Value;
        usr.Password = Utilerias.Encriptar(Pass.Value);
        LoggingBL bl = new LoggingBL();
        List<Usuario> lstusr = null;

        bool ret = bl.ValidarUsuario(usr);

        if (ret)
        {
            lstusr = bl.GetUsuario(usr);
            if (lstusr.Count > 0)
            {
                usr = lstusr.First<Usuario>();
                Session["Usuario"] = usr;
                switch (usr.Role.ID)
                {
                    case 1: Response.Redirect("Ranma.aspx"); break;
                    case 2: Response.Redirect("PATA.aspx", false); break;
                    case 3: Response.Redirect("Pretira.aspx", false); break;
                    default:
                        break;
                }
            }
        }
        else
        {
            Validacion.Style.Add("display", "");

        }
    }
}